#ifndef _MEMORY_POOL_HPP_20120428
#define _MEMORY_POOL_HPP_20120428

#include "base.hpp"

namespace mina
{
	class MemoryPool
	{
		public :
			MemoryPool(int page_size, int capacity_size);
			virtual ~MemoryPool();

			virtual void *allocate();
			virtual void deallocate(void * addr);

			int block_size() const { return _block_size; }

			bool internal(void * addr) const { return (addr >= _base && addr < _end); }

			bool empty() const { return (-1 == _head); }
			int free_block() const { return _free_block; }

			void display();

		private :
			void * get_addr(int index);
			int get_index(void * addr);

		private :
			int _head;
			int _free_block;

			const int _block_size;
			const int _block_num;

			char * _base;
			char * _end;
	};

}

#endif

